package com.yc.book.web;

import com.google.gson.Gson;
import com.yc.book.util.DBHelper;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet(name = "QueryServlet", value = "/QueryServlet")
public class QueryServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Map<String, Object>> list = DBHelper.selectListMap("select * from bm_book");
        String json = new Gson().toJson(list);
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.append(json);
    }
}
